package com.blu.scheduler;

import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.blu.job.MyJob;

@Configuration
public class myScheduler {
	
	@Bean
	public Scheduler scheduler() throws Exception {
		Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
		JobDetail jobDetail = JobBuilder.newJob(MyJob.class).withIdentity("job1", "JobGroup1").usingJobData("count",0).build();
		Trigger trigger = TriggerBuilder.newTrigger()
				.withIdentity("trigger1", "TriggerGroup1")
				.startNow()
				.withSchedule(SimpleScheduleBuilder.simpleSchedule().repeatSecondlyForever(65))
				.build();
		scheduler.scheduleJob(jobDetail,trigger);
		return scheduler;
	}
	
}
